import { WeaTools } from 'ecCom';

export const getWfRequestList = params => {
	let url = "";
	if(params.offical == "1"){
		url = "/api/offical/reqlist/getList";
	}else{
		if(params.actiontype === "baseinfo"){
			url = `/api/workflow/reqlist/${params.viewScope}BaseInfo`;
		}else if(params.actiontype === "countinfo"){
			url = `/api/workflow/reqlist/${params.viewScope}CountInfo`;
		}else if(params.actiontype === "splitpage"){
			url = "/api/workflow/reqlist/splitPageKey";
		}
	}
    return WeaTools.callApi(url, 'POST', params);
}

//获取连续处理信息
export const getContinnuationProcessInfo = params =>{
	return WeaTools.callApi('/api/workflow/reqlist/continnuationProcessInfo', 'POST', params);
}

//批量将列表数据全部置为已读
export const doReadIt = params =>{
	return WeaTools.callApi('/api/workflow/reqlist/doReadIt', 'POST', params);
}

//用于获取一些需要在执行列表查询前从后端获取的参数
export const getWfListParams = params =>{
    return WeaTools.callApi('/api/workflow/reqlist/getWfListParams', 'POST', params);
}

//根据前端传入的requestid获取不在代办中的流程requestid
export const getHendledReqIds = params =>{
    return WeaTools.callApi('/api/workflow/reqlist/getHendledReqIds', 'POST', params);
}

//批量签字意见
export const doBatchSubmit = (remark, selectRowKeys, datas, extDatas = {}) => {
	let requestIdStr = "";
	let belongUserStr = "";
	selectRowKeys.map(v=>{
		const arr = v.split("_");
		const requestid = arr[0];
		const belUserid = arr.length > 1 ? arr[1] : "";
		requestIdStr += requestid +",";
		belongUserStr += belUserid+",";
	});
	let params = {
		multiSubIds: requestIdStr,
		remark: remark,
		pagefromtype:1,
		belongtoUserids: belongUserStr,
        needBatchSubmit:1,
		...extDatas
	};
	return WeaTools.callApi('/api/workflow/reqform/requestBatchSubmit', 'POST', params);
}

/**获取未操作者**/
export const getUnoperators = params => {
    return WeaTools.callApi('/api/workflow/reqlist/getUnoperators', 'POST', params);
}
